﻿// Ao clicar no elemento com seletor "el", mostra/oculta elemento com seletor "alvo"
function toggle(el, alvo){
	// se el for link, desativar o href
	if($(el).attr("href")){
		$(el).attr("href", "javascript:;")
	}
	$(el).click(function(){
		$(this).toggleClass("expanded")
		$(alvo).slideToggle()
	})
}
//Mostra descrição das vagas disponiveis
function vagas(){
	$("#vagas div, #descricao").hide()
	$("#vagas li span").click(function(){
		$("#vagas li span").removeClass("active")
		$(this).toggleClass("active")
		item_desc = $(this).parent().find("div").html()
		fechar = "<button type='button'>Fechar</button>"
		$("#descricao").html(item_desc).append(fechar).slideDown()
		$("#descricao button").click(function(){
			$(this).parent().slideUp()
			$("#vagas li span").removeClass("active")
		})
	})
}
$(function(){
	vagas()
	$("ul, ol").each(function(){
		$(this).find("li:odd").addClass("odd")
		$(this).find("li:last-child").addClass("last")
	})
	$("tbody").each(function(){ $(this).find("tr:odd").addClass("odd") })
	$("a[rel=external]").attr("target", "_blank")
	// Show/hide
	$("#lateral #form-indique, #mapa-do-site").hide()
	toggle("#mapa", "#mapa-do-site")
	toggle("#lateral #indique", "#lateral #form-indique")
	//-----
	// Indique a um amigo
	$("#indique").click(function(){ $("#form-indique").animate({'top':'0'}, 'fast'); return false })
	$("#form-indique button").click(function(){ $("#form-indique").animate({'top':'-200px'}, 'fast') })
	//-----
	//Funções para compatibilidade dos IEs
	if (jQuery.browser.msie) {
		//Adiciona o :hover a todos os elementos no IE6, através da class .hover
		if(parseInt(jQuery.browser.version) == 6){
			$("button, li, #vagas span")
				.hover(
					function(){ $(this).addClass("hover") },
					function(){ $(this).removeClass("hover") }
				)
		}
		//-----
		//Adiciona o :focus a todos os elementos nos IEs, através da class .focus
		$("input, textarea, a, button")
			.focus(function(){ $(this).addClass("focus") })
			.blur(function(){ $(this).removeClass("focus") })
		//-----
	}
	//-----
	$('.cycle').cycle({fx:'fade', speed:1000, timeout:9000, pause:1, cleartype:1});
});

var scrollInt;var scrTime,scrSt,scrDist,scrDur,scrInt;function replaceAnchorLinks(){var anchors,i,targ,targarr;if(!document.getElementById)return;anchors=document.getElementsByTagName("a");for(i=0;i<anchors.length;i++){if(anchors[i].href.indexOf("#")!=-1&&anchors[i].href.indexOf(document.URL)!=-1){targ=anchors[i].href.substring(anchors[i].href.indexOf("#")+1);targarr=document.getElementsByName(targ);if(targarr.length){anchors[i].className=(targarr[0].offsetTop<anchors[i].offsetTop)?"up":"down";anchors[i].id="__"+targ;anchors[i].onmousedown=function(){scrollToAnchor(this.id.substring(2));return false;};anchors[i].href="javascript:;";}}}}function scrollPage(){scrTime+=scrInt;if(scrTime<scrDur){window.scrollTo(0,easeInOut(scrTime,scrSt,scrDist,scrDur));}else{window.scrollTo(0,scrSt+scrDist);clearInterval(scrollInt);}}function scrollToAnchor(aname){var anchors,i,ele;if(!document.getElementById)return;anchors=document.getElementsByTagName("a");for(i=0;i<anchors.length;i++){if(anchors[i].name==aname){ele=anchors[i];i=anchors.length;}}if(window.scrollY)scrSt=window.scrollY;else if(document.documentElement.scrollTop)scrSt=document.documentElement.scrollTop;else
scrSt=document.body.scrollTop;scrDist=ele.offsetTop-scrSt;scrDur=500;scrTime=0;scrInt=10;clearInterval(scrollInt);scrollInt=setInterval(scrollPage,scrInt);}function easeInOut(t,b,c,d){return c/2*(1-Math.cos(Math.PI*t/d))+b;}if(window.attachEvent){window.attachEvent("onload",replaceAnchorLinks);}else{window.onload=replaceAnchorLinks;}

//Aumentar e diminuir fonte
var hits = 3;
$fs = 13; //Aqui você específica qual o tamanho inicio da sua fonte
function fontSize(action, container){
	container = typeof(container) != 'undefined' ? container : 'div.texto'; //se não for especificado um container será 'div.texto'
	var hitIncrease = 0;
	var hitDecrease = 0;
	
	if (action == 'plus' && hits<6) {
		$fs += 1;
		hitIncrease = 1;
	}
	else if (action == 'minus' && hits>0) {
		$fs -= 1;
		hitDecrease = 1;
	} 
	$(container).css('font-size', $fs);
	
	if (hitIncrease == 1)hits+=1;
	else if (hitDecrease == 1)hits-=1;
}
$(function(){
	$('#decrease').click(function(){ fontSize('minus') }).blur();
	$('#increase').click(function(){ fontSize('plus') }).blur();
})